<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<title><?php echo ($name); ?></title>
<script src="__APP__/statics/jquery-1.9.1.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="__APP__/statics/css/jNotify.jquery.css" />
<script type="text/javascript" src="__APP__/statics/jNotify.jquery.js"></script>
<style>
 body{font-family:"微软雅黑";font-size:12px;color:#666666;background-color:#F9F9F6}
 *{margin: 0;} 
 a{text-decoration:none}
 img{border:0px}
.cat{background-color:#F9F9F6;margin-left:10px;z-index:0;}
.cat_list:hover{background-color:#fff;}
.title{background:url("__APP__/statics/tbg.gif");font-weight:bold}

#save{text-align:center;border:0;width:100%;height:40px;background-color:#fff;position:fixed;left:0px;bottom:0px;z-index:999;border:1px solid #DFDFDF;background-color:#DFDFDF;padding:5px;height:20px}
</style>

<script type="text/javascript" src="__APP__/statics/time/lhgcalendar.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/code/jquery-barcode.min.js"></script>
<script type="text/javascript">
	$(function(){
	    //时间选择
		$('[name=mindate]').calendar();
		$('[name=maxdate]').calendar();
	});
</script>
<style>
a{text-decoration:none;color:#232323}
.cat_list2{font-weight:bold;color:black;}

.cat_list3{color:#999999;text-decoration:line-through}
.cat_list3 a{color:#999999;text-decoration:line-through}
.cat_listc{background:#666666;}
.cat_list:hover{background:#3581fb;color:#fff}
.cat_list2:hover{background:#3581fb;color:#fff} 
.cat_list3:hover{background:#3581fb;color:#fff}

.page{height:20px;width:20px;border:1px solid #FF5500; text-align:center;vertical-align:middle;display:inline-block;color:#0066CC;cursor:pointer;}
.page:hover{color:#0066CC}
.page_current{height:20px;width:20px;border:1px solid #FF5500; text-align:center;vertical-align:middle;color:#FF0000;font-weight:bold;background:#FFEEE5;display:inline-block;}
</style>
<script language="javascript" src="__PUBLIC__/print/LodopFuncs.js"></script>
<script type="text/javascript" src="__PUBLIC__/code/jquery-barcode.min.js"></script>  
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0> 
	<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="install_lodop32.exe"></embed>
</object> 

<div style="margin:5px auto auto 10px;">
<form method="get" action="">
时间：<input name="mindate" value="<?php echo ($mindate); ?>"/>到<input name="maxdate" value="<?php echo ($maxdate); ?>"/>
订单号：<input type="text" name="order_id" value=""/>
<input id="settime" type="submit" value="确定">
</form>
</div>
<div class="cat" style="margin-top:5px;">
<table bordercolor="#DDDFFF" border="1" width="100%" style="border-collapse: collapse" cellpadding="3">
	<tr height="17" align="center">
		<td class="title" width="20"></td>
		<td class="title" width="140">订单号</td>
		<td class="title" width="150">下单时间</td>
		<td class="title" width="80">订单总额</td>
		<td class="title" width="60">优惠金额</td>
		<td class="title" width="60">应付金额</td>
		<td class="title" width="80">已支付金额</td>
		<td class="title" width="70">支付方式</td>
		<td class="title" width="60">支付状态</td>
		<td class="title" width="60">配送状态</td>
		<td class="title" width="60">收货人</td>
		<td class="title">操作</td>
	</tr>
<?php if(is_array($order)): $i = 0; $__LIST__ = $order;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$order): $mod = ($i % 2 );++$i; if($order["status"] != 'active' and $order["status"] != 'finish'): ?><tr height="20" bgcolor="#F1F5FA" class="cat_list3">
	<?php elseif($order["ship_status"] == '0'): ?>
	<tr height="20" bgcolor="#F1F5FA" class="cat_list2">
	<?php elseif($order["ship_status"] != '0'): ?>
	<tr height="20" bgcolor="#F1F5FA" class="cat_list"><?php endif; ?>
	    <td width="20"><input type="checkbox" name="order_id" value="<?php echo ($order["order_id"]); ?>"></td>
<?php if($order["status"] == 'finish'): ?><td width="140"><a href="javascript:;" onclick="getdetail(<?php echo ($order["order_id"]); ?>)"><?php echo ($order["order_id"]); ?></a><img src="__APP__/statics/icons/finish.gif"></td>
<?php elseif($order["status"] == 'dead'): ?>
		<td width="140"><a href="javascript:;" onclick="getdetail(<?php echo ($order["order_id"]); ?>)"><?php echo ($order["order_id"]); ?></a><img src="__APP__/statics/icons/dead.gif"></td>
<?php else: ?>
		<td width="140"><a href="javascript:;" onclick="getdetail(<?php echo ($order["order_id"]); ?>)"><?php echo ($order["order_id"]); ?></a></td><?php endif; ?>
		<td width="150"><?php echo (date("Y-m-d H:i:s",$order["create_time"])); ?></td>
		<td width="80">￥<?php echo $order['final_money']+$order['pmt_money']; ?></td>
		<td width="60">
<?php if($order["pmt_money"] != 0): ?><a href="javascript:prom(<?php echo ($order["order_id"]); ?>);">￥<?php echo ($order["pmt_money"]); ?></a>
<?php else: ?>￥<?php echo ($order["pmt_money"]); endif; ?>
		</td>
		<td width="70">￥<?php echo ($order["final_money"]); ?></td>
		<td width="70">￥<?php echo ($order["payed"]); ?></td>
		<td width="70" align="center"><?php echo ($order["pay_name"]); ?></td>
		<td width="60" align="center">
<?php switch($order["pay_status"]): case "1": ?><a href="javascript:pay(<?php echo ($order["order_id"]); ?>);"><img alt="已支付" src="__APP__/statics/infosuccess.gif" height="15"/><?php break;?>
		<?php case "0": if($order[payed] > 0): ?><a href="javascript:pay(<?php echo ($order["order_id"]); ?>);">部分支付</a>
		<?php else: ?>
		<img alt="未支付" src="__APP__/statics/infoerror.gif" height="15"/><?php endif; break; endswitch;?>
		</td>
		<td width="60" align="center">
<?php switch($order["ship_status"]): case "1": ?><a href="javascript:;" onclick="shipping(<?php echo ($order["order_id"]); ?>)"><img alt="已配送" src="__APP__/statics/infosuccess.gif" height="15"/></a><?php break;?>
		<?php default: ?><img alt="未配送" src="__APP__/statics/infoerror.gif" height="15"/><?php endswitch;?>
		</td>
		<td width="60"><?php echo ($order["ship_name"]); ?></td>
		<td>
<?php switch($order["status"]): case "active": if($order["pay_status"] == 0): ?><input onclick="setpay(<?php echo ($order["order_id"]); ?>)" type="button" value="支付">
		<?php else: ?>
		     <input onclick="setpay(<?php echo ($order["order_id"]); ?>)" disabled="true" type="button" value="支付"><?php endif; ?>

		<?php if($order["ship_status"] == 0): ?><input onclick="setship(<?php echo ($order["order_id"]); ?>)" type="button" value="发货">
		<?php else: ?>
		     <input onclick="setship(<?php echo ($order["order_id"]); ?>)" disabled="true" type="button" value="发货"><?php endif; ?>
			 <input onclick="finish(<?php echo ($order["order_id"]); ?>)" type="button" value="完成">
			 <input onclick="cancel(<?php echo ($order["order_id"]); ?>)" type="button" value="作废"><?php break;?>
	  <?php default: ?>
	         <input onclick="setpay(<?php echo ($order["order_id"]); ?>)" disabled="true" type="button" value="支付">
			 <input onclick="setship(<?php echo ($order["order_id"]); ?>)" disabled="true" type="button" value="发货">
			 <input onclick="finish(<?php echo ($order["order_id"]); ?>)" disabled="true" type="button" value="完成">
			 <input onclick="cancel(<?php echo ($order["order_id"]); ?>)" disabled="true" type="button" value="作废"><?php endswitch;?>
			<input onclick="printOrder(<?php echo ($order["order_id"]); ?>)" type="button" value="打印">
		</td>
	</tr><?php endforeach; endif; else: echo "" ;endif; ?>
</table>
</div>
<br><br>
<div id="order_detail" style="display:none"></div>
<div id="save">
     <div style="float:left">每页显示<input type="text" id="setnum" size="3" style="width:20px" value="<?php echo ($listnum); ?>"><input type="button" id="set" value="确定"></div>
     <div style="float:left;margin-left:30px;"><?php echo ($page); ?></div>
	 <div class="mar20" style="float:right">
		<input name="allselect" id="allselect" type="button" value="全选" />
		<input name="invert" id="invert" type="button" value="反选" />
		<input name="cancel" id="cancel" type="button" value="取消" />
		<input id="finishAll" name="output" type="button" value="批量完成"/>
		<input name="output" id="deadAll" type="button" value="批量作废" />
	</div>
</div>



<script src="__APP__/statics/webox/webox.js"></script>
<link href="__APP__/statics/webox/jquery-webox.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
function shipping(t){
       var id=t;
		$.webox({
			height:150,
			width:250,
			bgvisibel:true,
			title:'发货单详情',
			iframe:'__URL__/doc_ship/?order='+id
		});
}
//支付处理
function setpay(t){
       var id=t;
		$.webox({
			height:300,
			width:700,
			bgvisibel:true,
			title:'支付处理',
			iframe:'__URL__/setpay/?action=pay&order='+id
		});
}
//发货处理
function setship(t){
       var id=t;
		$.webox({
			height:300,
			width:700,
			bgvisibel:true,
			title:'发货处理',
			iframe:'__URL__/setship/?action=ship&order='+id
		});
}
//支付记录
function pay(t){
       var id=t;
		$.webox({
			height:200,
			width:500,
			bgvisibel:true,
			title:'订单支付记录',
			iframe:'__URL__/doc_pay/?order='+id
		});
}
//优惠记录
function prom(t){
       var id=t;
		$.webox({
			height:150,
			width:350,
			bgvisibel:true,
			title:id+'-优惠信息',
			iframe:'__URL__/doc_coupons/?order='+id
		});
}
//订单详情记录
function getdetail(t){
       var id=t;
		$.webox({
			height:450,
			width:820,
			bgvisibel:true,
			title:'订单:'+t+'详情',
			iframe:'__URL__/detail/?order='+id
		});
}

function printOrder(t){
	$.get('__URL__/detail',{'order':t},function(res){
		$("#order_detail").html(res);

		var LODOP;
	    LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));  
		var strBodyStyle="<style>"+document.getElementById("style1").innerHTML+"</style>";
		var strFormHtml=strBodyStyle+"<body>"+$("#orderlist").html()+"</body>";
		LODOP.SET_PRINT_STYLE("Bold",1);
		LODOP.SET_PRINT_PAGESIZE(2,"","","A5");
		LODOP.ADD_PRINT_HTM(10,5,1000,600,strFormHtml);
		var res=LODOP.PRINT();	
	})
}
</script>
<script>
$("#set").click(function(){
    var num=$("#setnum").val();
    $.ajax({
	     type:'GET',
		 url:'__URL__/setnum',
		 dataType:'json',
		 data:{'num':num},
		 success:function(){
		   location.reload();
		 }
	})
	
})
//完成订单
function finish(t){
	if(confirm('你确定要完成此订单吗？订单完成后将不能进行任何操作！请核实支付、配送是否完成')) {
		var id=t;
		$.ajax({
				 type:'GET',
				 url:'__URL__/set/?action=finish',
				 dataType:'html',
				 data:{'id':id},
				 success:function(){
				   location.reload();
				 }
			})
	}
}
//取消订单
function cancel(t){
	if(confirm('你确认作废此订单吗？订单作废后将不能进行任何操作！')) {
		var id=t;
		$.ajax({
				 type:'GET',
				 url:'__URL__/set/?action=dead',
				 dataType:'html',
				 data:{'id':id},
				 success:function(){
				   location.reload();
				 }
			})
	}
}
</script>


<script type="text/javascript">
$(document).ready(function(){

	// 全选        
	$("#allselect").click(function(){
		$(":checkbox").each(function(){
			$(this).attr("checked",true);
			$(this).parent().parent().css({"background-color":"blue","color":"White" });
		});    
	});
	
	//反选
	$("#invert").click(function(){
		$(":checkbox").each(function(){
			if($(this).attr("checked")){
				$(this).attr("checked",false);
				$(this).parent().parent().css({"background-color": "White","color":"black" });
			}else{
				$(this).attr("checked",true);
				$(this).parent().parent().css({"background-color": "blue","color":"White" });
			}
		});      
	});
	
	//取消
	$("#cancel").click(function(){
		$(":checkbox").each(function(){
			$(this).attr("checked",false);
			$(this).parent().parent().css({"background-color": "White","color":"black" });
		});      
	});

	$("#finishAll").click(function(){
		if(confirm('你确定要批量完成这些订单吗？完成后将不允许再进行操作')){
			var order_arr = new Array(); 
			$("[name=order_id]:checked").each(function(){
					order_arr.push($(this).val());
			})
			$.post('__URL__/finishAll',{'order_id':order_arr},function(res){
				jSuccess("<strong>操作成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
			})
		}
	})

	$("#deadAll").click(function(){
		if(confirm('你确定要取消这些订单吗？完成后将不允许再进行操作')){
			var order_arr = new Array(); 
			$("[name=order_id]:checked").each(function(){
					order_arr.push($(this).val());
			})
			$.post('__URL__/deadAll',{'order_id':order_arr},function(res){
				jSuccess("<strong>操作成功！</strong>",{TimeShown : 500,VerticalPosition : 'center',HorizontalPosition : 'center',onClosed:function(){location.reload();}})
			})
		}
	})

});
</script>